#!/bin/bash

#------------------Create Data------------------
echo "
# loop names	Original (128)      Split (128)     Original (512)      Split (512)
Accu          5240                8741.333333333  4586                7756
Edgecon       10648               20201.33333333  8492                18177.3333333333
Vflux         21145.3333333333    22076           18795.3333333333    20380
Iflux         10800               14392           8921                12678.6666666667
"> data1

#Wfflux        541.333333333333    564             564                 593.333333333333
#Sumwalls      233.333333333333    312             264                 332




#--------------------------Plot Data----------------------------

gnuplot <<END
reset
set grid xtics ytics mxtics mytics 
set term epslatex color 
set size 1,0.85


#set format "$%g$"
#set format xy "$%g$"

set xlabel " " 
set ylabel "Runtime (milli-seconds)"
#3,2

#set xrange [0:1024]
set yrange [:30000]

set style line 1 lt -1 lw 0.3
set key width -4.7
set key box linestyle 1 outside top

set key horiz
#set log x 2
#set log y 10
set border lw 2

set output "./Fig.tex"

set auto x
set style data histogram


set style histogram cluster gap 2 
set style fill solid
# -1 border -1 
#set boxwidth  2.0

set xtic rotate by 0
#set boxwidth 20 relative

plot 'data1' using 2:xtic(1) linecolor rgb '#EE0000' ti "Original (part. = 128)",\
     		      '' u 3 fill pattern 6 linecolor rgb '#000000' ti "Split (part. = 128)",\
  		      '' u 4 fill pattern 12 linecolor rgb '#000000' ti "Original (part. = 512)",\
   		      '' u 5 fill pattern 1 linecolor rgb '#00AA00' ti "Split (part. = 512)"
END


#-----------------------------------------

epstopdf Fig.eps

#-----------------------------------------
echo " \documentclass{article}
\usepackage{graphics}
\usepackage{nopageno}
%\usepackage{mathpazo}
\usepackage{txfonts}
\usepackage[usenames]{color}
	
\begin{document}
	
\begin{center}
  \small{
  \input{./Fig.tex}}
\end{center}
	
\end{document}" > Figure.tex
#-----------------------------------------

pdflatex Figure.tex
pdfcrop Figure.pdf

mv Figure-crop.pdf openmp-12proc.pdf

rm -f data* Figure.tex Figure.pdf Figure.log Figure.aux Figure.log Fig.eps Fig.tex Fig.pdf *~
